package com.example.administrator.xmut.http;

import java.io.Serializable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 课程描述类，包含课程的基本信息
 *
 * @author Jay
 *
 */
public class CourseBean implements Serializable {

	private static final long serialVersionUID = -2080529292063641408L;
	private String Course_name; // 课程名
	private String Course_address; // 上课地点
	private String Course_teacher; // 课程老师
	private String Course_week; // 课程周数

	public CourseBean() {

	}

	public CourseBean(String course_name, String course_address,
					  String course_teacher, String course_week) {
		Course_name = course_name;
		Course_address = course_address;
		Course_teacher = course_teacher;
		Course_week = course_week;
	}

	@Override
	public String toString() {
		return "课程信息 [课程名=" + Course_name + ", 上课地点=" + Course_address
				+ ", 课程老师=" + Course_teacher + ", 课程周数=" + Course_week + "]";
	}

	// 返回值为一二三四五六日
	// 周二第1,2节{第11-19周}
	public char getWeek() {
		return getCourse_week().charAt(1);
	}

	// 获取节数
	public int getTime() {
		Pattern pattern = Pattern.compile("\\d");
		Matcher matcher = pattern.matcher(getCourse_week());
		matcher.find();
		String result = matcher.group();
		int r = -1;
		if (result != null) {
			r = Integer.parseInt(result);
		}
		return r;
	}

	public String getCourse_name() {
		return Course_name;
	}

	public void setCourse_name(String course_name) {
		Course_name = course_name;
	}

	public String getCourse_address() {
		return Course_address;
	}

	public void setCourse_address(String course_address) {
		Course_address = course_address;
	}

	public String getCourse_teacher() {
		return Course_teacher;
	}

	public void setCourse_teacher(String course_teacher) {
		Course_teacher = course_teacher;
	}

	public String getCourse_week() {
		return Course_week;
	}

	public void setCourse_week(String course_week) {
		Course_week = course_week;
	}

}
